package com.koron.css2.newProjectCenter.impl;

import com.koron.css2.ServerInterface;
import com.koron.css2.newProjectCenter.bean.PjDelay;
import com.koron.css2.newProjectCenter.mapper.PjDelayMapper;
import com.koron.css2.serviceManage.bean.RequestBean;
import com.koron.css2.serviceManage.bean.UserInfoBean;
import com.koron.css2.serviceManage.utils.JsonUtils;
import com.koron.util.Constant;
import org.koron.ebs.mybatis.SessionFactory;
import org.swan.bean.MessageBean;

public class PjDelayUpdate implements ServerInterface {
    @Override
    public MessageBean<?> exec(SessionFactory factory, UserInfoBean userInfo, RequestBean req) {
        try {
            PjDelay pjDelay = JsonUtils.objectToPojo(req.getData(),PjDelay.class);
            PjDelayMapper pjDelayMapper = factory.getMapper(PjDelayMapper.class);

            // 1. updateTime, updateAccount, updateName
            pjDelay.setUpdateInfo(userInfo);
            // 2. 更新数据
            pjDelayMapper.update(pjDelay);
            // 3. 返回结果
            return MessageBean.create(Constant.MESSAGE_INT_SUCCESS,"延期数据更新成功",null);
        } catch (Exception e) {
            logger.error("延期数据更新失败",e);
            return MessageBean.create(Constant.MESSAGE_INT_FAIL,"延期数据更新失败",null);
        }
    }
}
